#!/usr/bin/node
const http=require('https'),
      log=console.log,
      url=require('url'),
      city=process.argv[2] || '石家庄',
     addr='https://api.66mz8.com/api/weather.php?location=' + city;
      //addr='https%3a%2f%2fapi.66mz8.com%2fapi%2fweather.php%3flocation=%e7%9f%b3%e5%ae%b6%e5%ba%84';
      log(global.encodeURI(addr));//make it to uri,change encode way

      let opt=url.parse(addr);
      opt.headers={
        'user-agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11
          '
      }

http.get(opt,(res)=>{




  log(`HTTP/${res.http} ${res.statusCode} ${res.statusMessage}`);
  log(res.headers);
  
  
});

